export default {
	/**
	 * @desc 首页
	 */
	state: {
		swiper: [],
		url: "http://vxinghe.com/m/index.php?c=home&a=lists&json=1&page=1&id=16",
		advert: [{
				url: 'http://vxinghe.com/data/uploads/2017/11/06/1509945744.jpg',
				path: '/news'
			},
			{
				url: 'http://vxinghe.com/data/uploads/2017/11/06/1509945744.jpg',
				path: '/news'
			}
		]
	},
	mutations: {
		/**
		 * @desc 保存数据
		 */
		updateSwiper(state, data) {
			state.swiper = data
		},
	},
	//处理mutations中的函数，区别是可以包含异步操作，使用this.$store.dispatch(actionName)调用
	actions: {
		/**
		 * @desc 请求数据
		 */
		getIndexSwiperData({
			commit,
			state
		}) {
			$.ajax({
				url: state.url,
				dataType: 'jsonp',
				jsonp: 'callback',
				success: function(result) {
					commit('updateSwiper', result)
					//console.log("IndexStore", result)
				},
				error: function(error) {
					console.log(error)
				}
			});
		}
	}
}